package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.response.DropdownItem;
import com.ssy.lingxi.order.model.vo.im.request.ImOrderPageVO;
import com.ssy.lingxi.order.model.vo.im.response.ImOrderVO;
import com.ssy.lingxi.order.service.im.IOrderCommunicationService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu IM实时通信相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-15
 */
@RestController
@RequestMapping("/order/im")
public class OrderCommunicationController {
    @Resource
    private IOrderCommunicationService orderCommunicationService;

    /**
     * 获取订单类型列表
     * @param headers HttpHeader信息
     * @return 前端显示的下拉菜单
     */
    @RequestMapping(value = "/type/list", method = RequestMethod.GET)
    public Wrapper<List<DropdownItem>> listOrderTypes(@RequestHeader HttpHeaders headers) {
        return orderCommunicationService.listOrderTypes(headers);
    }

    /**
     * 查询订单列表
     * @param headers HttpHeader信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<ImOrderVO>> memberImOrderList(@RequestHeader HttpHeaders headers, @Valid ImOrderPageVO pageVO) {
        return orderCommunicationService.pageOrders(headers, pageVO);
    }
}
